package com.novel.service;

import com.novel.mapper.NovelCategoryMapper;
import com.novel.pojo.novel.NovelCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.UUID;

@Service
@Transactional
public class NovelCategoryService {

    @Autowired
    private NovelCategoryMapper categoryMapper;

    /**
     * 添加小说的分类信息
     *
     * @param novelCategory 要添加的分类信息
     * @return true/false
     */
    public boolean addCategory(NovelCategory novelCategory) {
        //设置类别id
        novelCategory.setCId(UUID.randomUUID().toString());
        //插入信息
        return categoryMapper.insert(novelCategory) == 1;
    }

    /**
     * 查询所有小说类型信息
     */
    public List<NovelCategory> findAllCategory() {
        return categoryMapper.selectAll();
    }
}
